package com.ch.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import vo.Student;

/**
 * @author chenhong
 * @version 1.0.0
 * @ClassName ReturnObjectController.java
 * @Description TODO
 * @createTime 2020年12月17日 16:20:00
 */


@Controller
@RequestMapping("/returnParam")
public class ReturnObjectController {


    /**
     * @ResponseBody
     * 把处理器方法返回对象转化为json，通过HTTPServletResponse输出给浏览器
     *
     */
    @RequestMapping("/returnObject.do")
    @ResponseBody
    public Student returnObject(String name, Integer age){
        Student student = new Student();
        student.setName("陈洪");
        student.setAge(748);
        return student;

    }

    /**
     * @RequestMapping默认使用ContextType 为text  会中文乱码
     */
    @RequestMapping(value = "/returnStringText.do",produces = "text/plain;charset=utf-8")
    @ResponseBody
    public String returnString(){
        return "kk恰屎";
    }
}
